<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>美兰数据文化馆与图书馆</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/public.css" media="all">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/huazhi/images/favicon.ico"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <blockquote class="layui-elem-quote">
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <input class="layui-input searchval" type="text" placeholder="请输入搜索的内容">
                    </div>
                    <button class="layui-btn" id="search_btn" data-type="reload">搜索</button>
                </div>
            </blockquote>
            <table class="layui-hide" id="warehoursing" lay-filter="warehoursings"></table>
            <div id="laypage"></div>
        </div>
    </div>
</div>
<script type="text/html" id="table-chemical">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="info"></i>详情</a>

</script>
<input type="hidden" id="curnum" value="1">
<script src="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/layui.all.js"></script>
<script>
    layui.use(['table', 'laydate', 'layer', 'laypage'], function () {
            var $ = layui.jquery,
                table = layui.table,
                layer = layui.layer,
                laydate = layui.laydate,
                laypage = layui.laypage;

        var active = {
            reload: function () {  //data-type='reload'
                var searchval = $('.searchval').val();
                $("#curnum").val("1");
                table.reload('warehoursing', { //表格的id
                    where: {
                        key: searchval,
                        page: 1,
                        limit: 10,
                    },
                    text: {
                        none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
                    }
                })
            }
        };

        $('#search_btn').on('click', function () { //搜索的id
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });


            var limitcount = 10;
            table.render({
                elem: '#warehoursing'
                , url: "<%=request.getContextPath()%>/rest/process/getWarehoursing"
                , title: "采购入库单",
                height: 'full-125'
                , page: false
                , limit: limitcount
                , text: {
                    none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
                },
                defaultToolbar: ['filter', 'print']
                // ,skin: 'line' //表格风格
                , cols: [[
                    // {type: 'checkbox'}
                    {title: 'ID', width: 70, sort: true, fixed: 'left', type: 'numbers'},
                    {field: 'batchnumber', title: '入库单号', sort: true},
                    {field: 'applicant', title: '申请人', sort: true},
                    {field: 'applicationtime', title: '申请时间', sort: true},
                    {field: 'timestring', title: '入库时间', sort: true},
                    {field: 'status', title: '状态', sort: true},
                    {title: '操作', toolbar: '#table-chemical', align: "center", width: 100, fixed: "right"}
                ]],
                done: function (res, curr, count) {
                    if (res.errorMsg == null) {

                    } else {
                        layer.msg(res.errorMsg);
                    }
                    var curnum = $("#curnum").val();
                    $('.layui-table-fixed-r').removeClass('layui-hide');//列固定右侧
                    laypage.render({
                        elem: 'laypage'
                        , first: '首页'
                        , last: '尾页'
                        , groups: 5
                        , count: count
                        , curr: curnum
                        , limit: limitcount
                        , layout: ['prev', 'page', 'next', 'skip', 'count', 'limit']
                        , limits: [10, 15, 20]
                        , jump: function (obj, first) {
                            if (!first) {
                                curnum = obj.curr;
                                $("#curnum").val(curnum)
                                limitcount = obj.limit;
                                table.reload('warehoursing', { //表格的id
                                    where: {
                                        page: curnum,
                                        limit: limitcount
                                    }
                                })
                            }
                        }
                    })
                }
            });


        table.on('tool(warehoursings)', function (obj) {  //表格的lay-filter="userlists"
            var data = obj.data; //获得当前行所有数据
            // console.log(data) //当前容器的全部表单字段，名值对形式：{name: value}
            // alert(data.vip)
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            // JSON.stringify(data)
            if (obj.event == 'info') {
                info(data);
            }
        });

        function info(data){
            var clocess = "1";
            layer.open({
                title: "采购清单",
                type: 2,
                content:'<%=request.getContextPath()%>/rest/getRoute?type=instrument&url=chemical_warehoursing_info',
                //是否显示右上角关闭图标，默认为1，显示
                area: ['90%', '91%'],
                maxmin: true,
                shade: 0.6,
                anim: 4,
                skin: 'layui-layer-molv',
                resize: true,
                success: function (layero, index) {  //当你需要在层创建完毕时即执行一些语句，可以通过该回调 想相当于吧值转到子界面
                    var iframe = window['layui-layer-iframe' + index];
                    iframe.child(data.batchnumber)
                }, cancel: function (index, layero) {
                    layer.close(index)
                    clocess = "2"
                    return false;
                },
                end: function () {
                    if (clocess == "2") {

                    } else {
                        table.reload('applyTable')
                    }
                    return false;
                }
            });
        }









        });
</script>
</body>
</html>
